<?php 

/**
 * Joomla! 1.5 component arts_curriculum
 * @package    arts_curriculum
 * @subpackage
 * @author     Chris Borkowski {@link http://www.guggenheim.org}
 * @author     Created on 31-August-2009
 * @author     Modified on 22-January-2010
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' ); 

function taskMessage(){
$task =& JFactory::getURI();
$message = $task->getVar('task', 'No task found in URI', 'post','string');
return $message;
}
?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>

<div id="ac_category_page_box">
  
  <div id="ac_category_page_title">
    <!--title gets a fold after the ":" -->
    <h2><?php echo $this->items[0]->CATlink;?></h2>
  </div>
  
   <!-- the rest of the category view when no task string if found in the URI -->
  <?php if (taskMessage() == 'No task found in URI') :?>
  <div id="ac_category_page_description_above_fold">
    <!-- now for the 1st big trick -->
    <p><?php echo preg_replace('/{ac-break}(.*)|(\n)(.*){1,}/', '', $this->category->description); ?></p>
  </div>
  
  	<div id="ac_category_page_lessons_sub"><h4>Lessons</h4></div>
  	
  	<div id="ac_category_page_lessons_box"><!-- start ac_category_page_lessons_box" -->

    <?php foreach ($this->items as $item) : ?>
    <div class="ac_category_lesson_box_<?php echo $item->odd + 1; ?>"><!--count me -->
      <div id ="ac_cat_lesson_img"><a href="<?php echo $item->imagelink; ?>"><img src="/images/content/arts_curriculum/derivative1/<?php echo $item->image1; ?>" alt="<?php echo $item->title; ?>" /></a></div>
      <div id ="ac_cat_lesson_link"><?php echo $item->link; ?></div>
      <div id ="ac_cat_lesson_areas_box">
      <?php    // we need to first determin is were in the subjects array		
				// we need to make a subject/meduim link - this is tricky - we need to break the string items into array then process each array item
				// split the string by the "," delimeter and cast into an array then do an array explode 
				
				$subjects_array = explode(",", $item->subject);
				foreach ($subjects_array as $subjects){
					$sub_conditon= array ('English / Language Arts','Social Studies','Visual Arts','Technology','Math / Sciance');
					if (in_array( $subjects, $sub_conditon )) {
					$sublink = JRoute::_( 'index.php?option=com_arts_curriculum&view=sort&search='.$subjects);
					echo $sublinks = '<a href="'. $sublink .'" class="ac_cat_sub_link">'.$this->escape($subjects).'</a><br/>';
					}
					
				} 
				
				;?>      
      </div>
    
    </div><!--end ac_category_lesson_box -->
    
    <?php endforeach; ?>
  
  </div><!-- end ac_category_page_lessons_box" -->
  
  	<div id="ac_category_page_description_below_fold">
    <!-- now for the 2nd big trick..ta da ! the description is cut in half, thank you, I'll be here all week  -->
    <?php echo preg_replace('/(.*){ac-break}/', '', $this->category->description); ?> </div>
    
  
    <!-- we are adding a php if clause to fire in the vocabulary and related terms when called by the URI task string -->
  	
			<?php elseif (taskMessage() == "additional") :?>
			<div id="ac_category_addtional_box">
			<!-- now for the 3rd big trick -->
			<div id="ac_category_addtional_title"><h4>Additional Resources</h4></div>
			<p><?php echo $this->category->v_add ; ?></p>
			</div>
		  
			<?php elseif (taskMessage() == 'vocabulary') :?>
			<div id="ac_category_vocabulary_box">
			<!-- now for the 4th big trick -->
			<div id="ac_category_vocabulary_title"><h4>Vocabulary</h4></div>
			<p><?php echo $this->category->v_main_body ; ?></p>
			</div>
			<?php endif ;?>

</div><!--end ac page box-->


	</td>
</tr>
</table>



